home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / misc / VMM_src.lha / VMM / tools / VMMStat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-16  |  1.8 KB  |  67 lines

  1. #include <exec/types.h>
  2. #include <exec/io.h>
  3. #include <exec/memory.h>
  4. #include <clib/exec_protos.h>
  5. #include <clib/dos_protos.h>
  6. #include <clib/alib_stdio_protos.h>
  7. #ifdef __GNUC__
  8. #include "../shared_defs.h"
  9. #else
  10. #include "/shared_defs.h"
  11. #endif
  12.  
  13. int main (void)
  14.  
  15. {
  16. struct VMMsg *StatMsg;
  17. struct MsgPort *VMMPort;
  18. ULONG ReplySignal;
  19.  
  20. if ((ReplySignal = AllocSignal (-1L)) == -1)
  21.   {
  22.   printf ("Could not allocate signal\n");
  23.   return (5);
  24.   }
  25.  
  26. if ((StatMsg = AllocMem (sizeof (struct VMMsg), MEMF_PUBLIC)) == NULL)
  27.   {
  28.   printf ("Not enough memory for message\n");
  29.   FreeSignal (ReplySignal);
  30.   return (5);
  31.   }
  32.  
  33. StatMsg->VMSender = FindTask (NULL);
  34. StatMsg->VMCommand = VMCMD_AskStat;
  35. StatMsg->ReplySignal = ReplySignal;
  36.  
  37. Forbid ();
  38. if ((VMMPort = FindPort (VMPORTNAME)) == NULL)
  39.   {
  40.   Permit ();
  41.   FreeMem (StatMsg, sizeof (struct VMMsg));
  42.   FreeSignal (ReplySignal);
  43.   printf ("VMM is not running\n");
  44.   return (0);
  45.   }
  46.  
  47. PutMsg (VMMPort, (struct Message*)StatMsg);
  48. Permit ();
  49.  
  50. Wait (1L << ReplySignal);
  51.  
  52. printf ("VMMStat V2.1\n\n");
  53. printf ("  Overall VM size:                 %8ld\n", StatMsg->st_VMSize);
  54. printf ("  VM free:                         %8ld\n", StatMsg->st_VMFree);
  55. printf ("  Number of pagefaults:            %8ld\n", StatMsg->st_Faults);
  56. printf ("  Number of pages read:            %8ld\n", StatMsg->st_PagesRead);
  57. printf ("  Number of pages written:         %8ld\n", StatMsg->st_PagesWritten);
  58. printf ("  Number of allocated page frames: %8ld\n", StatMsg->st_Frames);
  59. printf ("  Number of pages used on device:  %8ld\n", StatMsg->st_PagesUsed);
  60. printf ("  Pagesize:                        %8ld\n", StatMsg->st_PageSize);
  61. printf ("  Number of TrapStructs free:      %8ld\n", StatMsg->st_TrapStructsFree);
  62.  
  63. FreeMem (StatMsg, sizeof (struct VMMsg));
  64. FreeSignal (ReplySignal);
  65. return (0);
  66. }
  67.